import http from '../../request/api';

const state = {
    bookList: [],
    offlineList: [],
}

const getters = {

}

const mutations = {
    setBookList(state, v) {
        console.log('setBookList', v);
        state.bookList = v
    },
    setOfflineList(state, v) {
        console.log('setOfflineList', v);
        state.offlineList = v
    },
}
const actions = {
    getBookList: ({ commit }) => {
        return new Promise(async r => {
            let res = await http.getBookList({ page: 1, pageSize: 9999 });
            commit('setBookList', res.data);
            r(res);
        })
    },
    getOfflineList: ({ commit }) => {
        return new Promise(async r => {
            let res = await http.getOfflineList({ page: 1, pageSize: 9999 });
            commit('setOfflineList', res.data);
            r(res);
        })
    }
}

export default {
    state,
    getters,
    actions,
    mutations
}